home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C++ / Snippets / QD3D Juggler / Juggler Sources / CQD3DGimbalPane.cp < prev    next >
Encoding:
Text File  |  1995-12-27  |  1.9 KB  |  75 lines  |  [TEXT/CWIE]

  1. //
  2. //    CQD3DGimbalPane.cp
  3. //
  4. //    class CQD3DGimbalPane
  5. //    A class for displaying a QuickDraw 3D view where
  6. //    dragging in the scene moves the camera around such 
  7. //    that up is always up (+z direction).
  8. //
  9. //    by James Jennings
  10. //    Started November 24, 1995
  11. //
  12.  
  13. #include "CQD3DGimbalPane.h"
  14. #include "CCameraMover.h"
  15. #include "StQ3Disposer.h"
  16. #include "QD3D Debug Macros.h"
  17.  
  18. CQD3DGimbalPane::CQD3DGimbalPane()
  19. {    // default constructor
  20.     // Does nothing. Must call FinishCreate() later.
  21. }
  22.  
  23. CQD3DGimbalPane::CQD3DGimbalPane(const CQD3DGimbalPane &inOriginal) 
  24.     : CQD3DPane(inOriginal)
  25. {    // copy constructor
  26. }
  27.     
  28. CQD3DGimbalPane::CQD3DGimbalPane(LStream *inStream)    
  29.     : CQD3DPane(inStream)
  30. {    // stream constructor
  31.     // Does nothing. Must call FinishCreate() later.
  32. }
  33.  
  34. CQD3DGimbalPane::~CQD3DGimbalPane()
  35. {
  36. }
  37.  
  38. void
  39. CQD3DGimbalPane::ClickSelf( const SMouseDownEvent&    inMouseDown)
  40. {    // the method that does the "gimballing"
  41.     FocusDraw();
  42.     Point oldMouse, newMouse;
  43.     oldMouse = newMouse = inMouseDown.whereLocal;
  44.     
  45.     CCameraMover cameraMover(mView);
  46.     
  47.     while (StillDown()) {
  48.         oldMouse = newMouse;
  49.         ::GetMouse(&newMouse);
  50.         if ( !::EqualPt(oldMouse, newMouse)) {
  51.             // convert change in mouse into a change in camera position
  52.             // (quick and dirty for now: do careful math later)
  53.             cameraMover.Move(    (oldMouse.h - newMouse.h) * kQ3Pi/200,
  54.                                 (oldMouse.v - newMouse.v) * kQ3Pi/200    );
  55.             // Allow sub-classes to have their say
  56.             ClickLoop(inMouseDown.macEvent);
  57.             // Update the scene
  58.             DrawSelf();
  59.         } else {    // mouse didn't move
  60.             // Allow sub-classes to have their say
  61.             if (ClickLoop(inMouseDown.macEvent))
  62.                 // Update the scene IF the sub-class says so.
  63.                 DrawSelf();
  64.         }
  65.     }
  66. }
  67.  
  68. Boolean
  69. CQD3DGimbalPane::ClickLoop(const EventRecord &/*inMacEvent*/)
  70. {    // Subclasses may override to modify the scene in some other way.
  71.     // Return true if you want to redraw the scene (because you're
  72.     // animating something for example.)
  73.     return false;
  74. }
  75.